package com.kfm.jdbc.day0405;

public class Demo08 {


    public static void main(String[] args) {
        // 主线程中创建的ThreadLocal对象
        ThreadLocal<String> threadLocal = new ThreadLocal<>();

        threadLocal.set("hello");

        System.out.println(threadLocal.get());

        // 子线程中获取主线程中的ThreadLocal对象
        new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadLocal<String> t = new ThreadLocal<>();
                t.set("child");
                System.out.println(threadLocal.get());
            }
        }).start();

    }
}
